//
//  ViewController.swift
//  SwiftTest
//
//  Created by 李江湖 on 2018/7/12.
//  Copyright © 2018年 李江湖. All rights reserved.
//

import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
    let btnStartTag = 1000
    let name_link_tuples = [("swift版TableView","SwiftTableViewController"),
                            ("swift版CollectionView","SwiftCollectionViewController"),
                            ("swift版网络请求","AFNViewController"),
                            ("swift一个有趣的Lable显示动画","SwiftLableAnimationController"),
                            ("上下拉刷新MJRefresh","MJRefreshController"),]

    @IBOutlet weak var table: UITableView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }
    
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.name_link_tuples.count
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 30;
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let model = self.name_link_tuples[indexPath.row]
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! ViewCell
        cell.titleLab.text = model.0
        return cell
    }
    
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 0.01;
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let model = self.name_link_tuples[indexPath.row]
        let vcStr = "SwiftTest." + model.1
        let vc  = (NSClassFromString(vcStr) as! UIViewController.Type).init()
        self.navigationController?.pushViewController(vc, animated: true)
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

